import { ADD_GOOAS } from "./mutation-type";

export default{
    [ADD_GOOAS](state,{goodsId,goodsName,smallImage,goodsPrice}){
        let shopCart = state.shopCart;
        //判断商品是否存在
        if(shopCart[goodsId]){
            shopCart[goodsId]["num"]++;
        } else{
            shopCart[goodsId] = {
                "num":0,
                "id":goodsId,
                "name":goodsName,
                "small_Image":goodsName,
                "price":goodsPrice,
                "checked":true
            }
        }
        state.shopCart = {...shopCart};
    }
}